﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.controllers {
    import net.wooga.pets.loading.vos.*;
    import net.wooga.pets.events.*;
    import net.wooga.pets.models.world.vos.*;
    import net.wooga.pets.constants.*;
    import org.robotlegs.mvcs.*;
    import net.wooga.pets.models.world.*;

    public class CollectMissionRewardCommand extends Command {

        public var event:InfoEvent;
        public var missions:MissionModel;

        override public function execute():void{
            var _local1:RequestEvent = new RequestEvent(EventConstants.SEND_REQUEST, this.onCollect);
            _local1.addRequest("collect_mission_reward", {id:this.event.id});
            dispatch(_local1);
        }
        private function onCollect(_arg1:ResultVO):void{
            var _local2:Object;
            var _local3:MissionVO;
            if (_arg1.success){
                _local2 = _arg1.data.collect_mission_reward;
                this.track();
                dispatch(new InfoEvent(EventConstants.UPDATE_USER_DATA, null, _local2));
                _local3 = this.missions.removeMission(this.event.id);
                dispatch(new InfoEvent(EventConstants.CREATE_POPUP, GameConstants.MISSION_REWARD_POPUP, _local3));
                if (((_local3) && (!(_local3.isLevelMission)))){
                    dispatch(new InfoEvent(EventConstants.INIT_MISSION));
                };
            };
        }
        private function track():void{
            var _local1:Object = new Object();
            _local1.type = "mission";
            _local1.st1 = "collect";
            _local1.st2 = this.event.info;
            dispatch(new TrackingEvent(TrackingConst.TRACK, TrackingConst.EVENT, _local1));
        }

    }
}//package net.wooga.pets.controllers 
